import QtQuick 2.0
import QtQuick.Controls 2.1
import "../../common"
import "../../../js/util.js" as Util
import "../../../js/UI.js" as Style

Page {
    id: persominfo
    property Component component: null
    property var objects: new Array
    signal cancel()
    onCancel: {
        Util.popView(objects)
    }

    Component.onCompleted: {
        m_name_text.text = DatabaseEngine.persondata.name
        m_sex_text.text = DatabaseEngine.persondata.sex
        m_phone_text.text = DatabaseEngine.persondata.phone
        m_email_text.text = DatabaseEngine.persondata.email
        m_id_text.text = DatabaseEngine.persondata.id
        m_major_text.text = DatabaseEngine.persondata.major
        m_time_text.text = DatabaseEngine.persondata.time
    }

    Connections{
        target: DatabaseEngine
        onPersondataChanged:{
            m_phone_text.text = DatabaseEngine.persondata.phone
            m_email_text.text = DatabaseEngine.persondata.email
        }
    }

    ATitle{
        id: m_titleID
        anchors.top: parent.top
        anchors.left: parent.left
        m_text: qsTr("个人信息")
        m_textcol:Style.fonttilteColor
        onBackSignal:subpageSignal(1,-1)
        rightItem:BButton{
            anchors.fill: parent
            enabled: true
            m_text.text: "修改信息"
            m_text.font.pointSize: 14
            onSigClick: {
                Util.pushView(component,objects,"qrc:/qml/form/personpage/PersonInfoChanged.qml",persominfo,{})
            }
        }
    }

    Column{
        id: column
        width: parent.width
        height: parent.height
        anchors.top: m_titleID.bottom
        Rectangle{
            width: parent.width
            height: 0.3*m_lineValue
            color: "#f6f5ec"
        }
        BaseLine{
            width: parent.width
            height: m_lineValue*1.65
            anchors.left: parent.left
            AText{
                id: userimage
                anchors.left: parent.left
                anchors.leftMargin: 0.3*m_lineValue
                anchors.verticalCenter: parent.verticalCenter
                text: qsTr("头像")
                font.pointSize: 14
                color: "#000000"
            }
            HeadImage{
                id: image
                width: height
                height: parent.height*0.8
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: m_lineValue*0.5
                isCallImage: true
                m_source: "qrc:/image/personpage/headimage.jpg"
            }
        }
        Rectangle{
            width: parent.width
            height: 0.3*m_lineValue
            color: "#f6f5ec"
        }
        Item{
            width: parent.width
            height: childrenRect.height
            BaseLine{
                id: username
                height: m_lineValue
                width: parent.width
                anchors.top: parent.top
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("姓名")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_name_text
                    anchors.right: parent.right
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.name
                    font.pointSize: 14
                    color: "#46485f"
                }
                SplitLine {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        leftMargin: m_lineValue*0.3
                        right: parent.right;
                    }
                }
            }
            BaseLine{
                id: sex
                height: m_lineValue
                width: parent.width
                anchors.top: username.bottom
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("性别")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_sex_text
                    anchors.right: parent.right
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.sex
                    font.pointSize: 14
                    color: "#46485f"
                }
            }
        }
        Rectangle{
            width: parent.width
            height: 0.3*m_lineValue
            color: "#f6f5ec"
        }
        Item{
            width: parent.width
            height: childrenRect.height
            BaseLine{
                id: phone
                height: m_lineValue
                width: parent.width
                anchors.top: parent.top
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("手机")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_phone_text
                    anchors.right: m_arrow.left
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.phone
                    font.pointSize: 14
                    color: "#46485f"
                }
                Image {
                    id: m_arrow
                    anchors.right: parent.right
                    anchors.rightMargin: m_lineValue*0.2
                    anchors.verticalCenter: parent.verticalCenter
                    sourceSize: Qt.size(m_lineValue*0.3,m_lineValue*0.3)
                    source: "qrc:/image/arrow.png"
                }
                onMouseclickSignal: {
                    Util.pushView(component,objects,"qrc:/qml/form/personpage/PersonInfoChanged.qml",persominfo,{})
                }

                SplitLine {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        leftMargin: m_lineValue*0.3
                        right: parent.right;
                    }
                }
            }
            BaseLine{
                id: emil
                height: m_lineValue
                width: parent.width
                anchors.top: phone.bottom
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("邮箱")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_email_text
                    anchors.right: m_arrow1.left
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.email
                    font.pointSize: 14
                    color: "#46485f"
                }
                Image {
                    id: m_arrow1
                    anchors.right: parent.right
                    anchors.rightMargin: m_lineValue*0.2
                    anchors.verticalCenter: parent.verticalCenter
                    sourceSize: Qt.size(m_lineValue*0.3,m_lineValue*0.3)
                    source: "qrc:/image/arrow.png"
                }
                onMouseclickSignal: {
                    Util.pushView(component,objects,"qrc:/qml/form/personpage/PersonInfoChanged.qml",persominfo,{})
                }

                SplitLine {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        leftMargin: m_lineValue*0.3
                        right: parent.right;
                    }
                }
            }
            BaseLine{
                id: m_id
                height: m_lineValue
                width: parent.width
                anchors.top: emil.bottom
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("学号")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_id_text
                    anchors.right: parent.right
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.id
                    font.pointSize: 14
                    color: "#46485f"
                }
                SplitLine {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        leftMargin: m_lineValue*0.3
                        right: parent.right;
                    }
                }
            }
            BaseLine{
                id: m_class
                height: m_lineValue
                width: parent.width
                anchors.top: m_id.bottom
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("所属班级")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_major_text
                    anchors.right: parent.right
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.major
                    font.pointSize: 14
                    color: "#46485f"
                }
                SplitLine {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        leftMargin: m_lineValue*0.3
                        right: parent.right;
                    }
                }
            }
            BaseLine{
                id: m_time
                height: m_lineValue
                width: parent.width
                anchors.top: m_class.bottom
                AText{
                    anchors.left: parent.left
                    anchors.leftMargin: 0.3*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("入学时间")
                    font.pointSize: 14
                    color: "#000000"
                }
                AText{
                    id: m_time_text
                    anchors.right: parent.right
                    anchors.rightMargin: 0.2*m_lineValue
                    anchors.verticalCenter: parent.verticalCenter
//                    text: DatabaseEngine.persondata.time
                    font.pointSize: 14
                    color: "#46485f"
                }
                SplitLine {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        leftMargin: m_lineValue*0.3
                        right: parent.right;
                    }
                }
            }
        }
    }

}
